//
//  LinkerCell.m
//  GC_OC
//
//  Created by tuibian  on 2022/5/26.
//

#import "LinkerCell.h"
#import <UIButton+WebCache.h>
#import <YYKit/YYKit.h>

@implementation LinkerCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor clearColor];


        self.container = [UIView new];
        self.container.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.container];
        
        UIView *vline2 = [UIView new];
        self.vline2 = vline2;
        vline2.backgroundColor = XHUIColorFromRGB(0x979797);
        [self.container addSubview:vline2];
        UIView *vline3 = [UIView new];
        vline3.backgroundColor = XHUIColorFromRGB(0x979797);
        self.vline3 = vline3;
        [self.container addSubview:vline3];
        UIView *vline = [UIView new];
        vline.backgroundColor = XHUIColorFromRGB(0x979797);
        [self.container addSubview:vline];
        
        self.aidvline = [UIView new];
        self.aidvline.backgroundColor = XHUIColorFromRGB(0x979797);
        [self.container addSubview:self.aidvline];
        
        
        UIView *hline = [UIView new];
        hline.backgroundColor = XHUIColorFromRGB(0x979797);
        [self.container addSubview:hline];
        
        UILabel *titleLabel = [UILabel new];
        self.titleLabel = titleLabel;
        titleLabel.textColor = XHUIColorFromRGB(0x999898);
        titleLabel.font = [UIFont systemFontOfSize:14 weight:UIFontWeightMedium];
        [self.container addSubview:titleLabel];

        self.playImageView = [UIImageView new];
        [self.container addSubview:self.playImageView];
        
        [self.container mas_makeConstraints:^(MASConstraintMaker *make) {
            make.edges.equalTo(self.contentView);
        }];
        
        [vline2 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.container).offset(35);
            make.top.bottom.equalTo(self.container).offset(0);
            make.width.mas_equalTo(1);
        }];
        
        [vline3 mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(vline2.mas_right).offset(20);
            make.top.bottom.equalTo(self.container).offset(0);
            make.width.mas_equalTo(1);
        }];
        
        [vline mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.container).offset(91);
            make.top.equalTo(self.container).offset(0);
            make.height.mas_equalTo(26);
            make.width.mas_equalTo(1);
        }];
        [self.aidvline mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.container).offset(91);
            make.top.equalTo(vline.mas_bottom).offset(0);
            make.height.mas_equalTo(14);
            make.width.mas_equalTo(1);
        }];
        
        [hline mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(vline.mas_right).offset(0);
            make.top.equalTo(vline.mas_bottom).offset(-1);
            make.height.mas_equalTo(1);
            make.width.mas_equalTo(10);
        }];
        
        [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(hline.mas_right).offset(0);
            make.centerY.equalTo(hline);
            make.height.mas_equalTo(18);
            make.right.equalTo(self.container).offset(-52);
        }];
        
        [self.playImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.right.equalTo(self.container.mas_right).offset(-15);
            make.centerY.equalTo(hline);
            make.height.width.mas_equalTo(24);
        }];

    }
    return self;
}

- (void)configCell:(LinkerModel *)info {
    self.titleLabel.text = info.name;
    
    NSNumber *isSelect = info.isSelect;
    
    self.titleLabel.textColor = XHUIColorFromRGB(0x999898);
    self.playImageView.hidden = YES;
    if ([isSelect isEqual:@1]) {
        self.playImageView.hidden = NO;
        self.titleLabel.textColor = XHUIColorFromRGB(0x0091FF);

    }
    
//    self.playImageView.image = [UIImage imageNamed:@"bofangzhong备份"];
    
    NSString *imagePath = [[NSBundle mainBundle] pathForResource:@"Untitled" ofType:@"gif"];
    NSData *imageData = [NSData dataWithContentsOfFile:imagePath];
    UIImage *image = [UIImage sd_imageWithGIFData:imageData];
    self.playImageView.image = image;
}


@end
